﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace vkUpploaderLib.HttpHelpers
{
    using System.Windows.Forms;
    using Exceptions;
    using Resourses;

    class AuthWindow : WebBrowserWindow
    {
        public DialogResult DialogResult;

        public AuthWindow(string url)
            : base(url, String.Format("{0}: {1}", StringResources.ProductName, StringResources.Auth))
        {
            NavigatedHandler += _webBrowser_Navigated;
            CreateControls();
        }

        void _webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.ToString() == AuthHelper.AuthUrl)
                return;

            if (AuthHelper.ProcessAuthResult(e.Url.ToString()))
                DialogResult = DialogResult.OK;
            _form.Close();
        }

       
    }
}
